package com.weiyirong99.crm.app.util;

import android.os.Build;
import android.util.Log;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.OvershootInterpolator;
import android.view.animation.TranslateAnimation;

import androidx.annotation.RequiresApi;

public class MyClick implements View.OnClickListener {
    private long startTime;
    private View.OnClickListener l;

    // private onClickListener a;

    public MyClick(View.OnClickListener l) {
        this.l = l;
    }


    @RequiresApi(api = Build.VERSION_CODES.M)
    @Override
    public void onClick(View v) {
        long currentTime = System.currentTimeMillis();

        if ((currentTime - startTime) >= 500) {
         //   overshootAnimation(1, v);
            l.onClick(v);

            startTime = currentTime;
            Log.e("TAG", "onClick: 22222");
        } else {
            Log.e("TAG", "onClick: 11111");
        }
    }


    public void overshootAnimation(int counts, View view) {
        TranslateAnimation animation = new TranslateAnimation(0, 0, 0, 5);
        animation.setInterpolator(new OvershootInterpolator());
        animation.setDuration(20);
        animation.setRepeatCount(counts);
        animation.setRepeatMode(Animation.REVERSE);
        view.startAnimation(animation);
    }





}


//interface onClickListener {
//    void onClick(View v);
//}